package com.tanhua.server.controller;

import com.tanhua.dubbo.pojo.Answers;
import com.tanhua.server.service.TestSoulService;
import com.tanhua.server.vo.QuestionnaireVo;
import com.tanhua.server.vo.TestResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    /**
     * @return: java.util.List<com.tanhua.server.vo.QuestionnaireVo>
     * @author: LPW
     * @date: 2021/6/21 14:49
     * @description: 灵魂测试问卷列表
     */
    @GetMapping
    public List<QuestionnaireVo> soulQuestionnaire() {
        List<QuestionnaireVo> questionnaireVos = this.testSoulService.soulQuestionnaire();
        return questionnaireVos;
    }

    //提交问卷答案
    @PostMapping
    public Object soulTestAnswer(@RequestBody Map<String, List<Answers>> answers) {
        List<Answers> answersList = answers.get("answers");
        return this.testSoulService.soulTestAnswer(answersList);
    }

    /**
     * 测试结果
     *
     * @param reportId
     * @return
     */
    @GetMapping("/report/{id}")
    public TestResultVo testResult(@PathVariable("id") Long reportId) {
        return this.testSoulService.testResult(reportId);
    }
}
